package cn.starrysky108.simpleerp.core.enums;

/**
 * @author Carl Lee
 * 响应状态枚举
 */
public enum ResultCodeEnum {
    /*** 通用部分 100 - 599***/
    SUCCESS(200, "成功"),
    FAIL(-1, "失败"),
    REDIRECT(301, "重定向"),
    BAD_REQUEST(400, "错误请求"),
    UNAUTHORIZED(401, "未授权"),
    LOGIN_FAIL(401, "用户名或密码错误"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "未找到"),
    SERVER_ERROR(500, "系统异常"),

    /**
     * token相关异常
     */
    TOKEN_ILLEGAL(1001, "token非法，当前token已被强制退出或token失效，请重新登录"),
    TOKEN_EXPIRED(1002, "accessToken过期，请访问 /usr/token 获取最新token或重新登录"),
    REFRESH_TOKEN_EXPIRED(1003, "refreshToken过期，请访问 /usr/token 获取最新token或重新登录"),
    /**
     * 文件异常
     */
    FILE_LOAD_FAILED(1050, "文件加载失败"),
    FILE_STORE_FAILED(1051, "文件保存失败"),
    /**
     * 通用部分
     */
    VALIDATE_FAIL(-2, "参数校验异常"),
    ASSERT_FAIL(-3, "assert条件不满足"),
    BIND_FAIL(-4, "参数绑定异常");

    /**
     * 响应状态码
     */
    private Integer code;
    /**
     * 响应状态信息
     */
    private String message;

    ResultCodeEnum(Integer code, String msg) {
        this.code = code;
        this.message = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "ResultCodeEnum{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
